package com.lin.blog.web;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.lin.blog.entity.Menu;
import com.lin.blog.service.MenuService;

@Namespace("/")
@Results({ @Result(name = CrudActionSupport.RELOAD, location = "home.action", type = "redirect") })
public class HomeAction extends CrudActionSupport {

	private static final long serialVersionUID = 5896333413409257061L;
	@Autowired
	private MenuService menuService;
	private Menu menu;

	@Override
	public String list() throws Exception {
		// menu = menuService.get(1l);
		// menu.setName("Home1");
		// menu.setDescription("Index");
		// menuService.update(menu);
		// menu = menuService.get(1l);
		// afterAction();
		return SUCCESS;
	}

	@Override
	public String input() throws Exception {
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		return null;
	}

	@Override
	public String delete() throws Exception {
		return null;
	}

	@Override
	public void afterAction() {
		ServletActionContext.getRequest().setAttribute("menu", menu);
	}

	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

}
